package com.zhuojy.equity.mall.admin.service.message;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhuojy.equity.mall.admin.common.entity.po.TCandidatePO;
import com.zhuojy.equity.mall.admin.common.pojo.JsonResult;
import com.zhuojy.equity.mall.admin.dal.mapper.message.TCandidateMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @Author:LYL
 * @Date 2024/4/16 16:48
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class TCandidateService extends ServiceImpl<TCandidateMapper, TCandidatePO> {
    public void addCandidate(TCandidatePO tCandidatePO) {
        tCandidatePO.setApplyForDate(new Date());
        this.baseMapper.insert(tCandidatePO);
    }

    public JsonResult findCandidateFenYe(TCandidatePO tCandidatePO, Integer pageNum, Integer pageSize) {
        Page<TCandidatePO> tCandidatePOPage = new Page<>(pageNum, pageSize);
        IPage<TCandidatePO> candidateFenYe = this.baseMapper.findCandidateFenYe(tCandidatePO, tCandidatePOPage);
        return JsonResult.success(candidateFenYe.getRecords(),candidateFenYe.getTotal());
    }

    public void updateStatusById(TCandidatePO tCandidatePO) {
        this.baseMapper.updateStatusById(tCandidatePO);
    }

    public TCandidatePO findCandidateById(Long id) {
        return this.baseMapper.selectById(id);
    }
}
